''' 运算符重写 （位运算，方向位运算，复合位运算）'''


class Mynumber():
    def __init__(self,data):
        self.data = data

    def __repr__(self):
        return "运算符重写：%d" % self.data

    def __and__(self, other):
        return self.data & other.data

    def __iand__(self, other):
        self.data &= other.data
        return self.data

    def __ror__(self, other):
        return self.data | other.data

    def __or__(self, other):
        return self.data | other.data

    def __lshift__(self, other):
        return self.data << other

    def __rshift__(self, other):
        return self.data >> other


mn1 = Mynumber(6)
mn2 = Mynumber(4)

print(mn1 & mn2)

mn1 &= mn2
print(mn1)

print(mn1 | 9)
print(9 | mn1)

print(mn1 << 2)
print(mn1 >> 1)
